<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="viewport" content="width=1000, initial-scale=1.0, maximum-scale=1.0">
	    <!-- Loading Bootstrap -->
	    <link href="Public/Admin/Flat/dist/css/vendor/bootstrap.min.css" rel="stylesheet">
	    <!-- Loading Flat UI -->
	    <link href="Public/Admin/Flat/dist/css/flat-ui.css" rel="stylesheet">
	    <link href="Public/Admin/Flat/docs/assets/css/demo.css" rel="stylesheet">
	    <link rel="shortcut icon" href="Public/Admin/Flat/img/favicon.ico">
		<script src="Public/Admin/jquery-1.8.2.min.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			$(function(){
				//表单的提交事件
				$('#navform').submit(function(){
					//抓取form表单的所有内容，不用挨个抓取
					var formData = $(this).serialize();
					//alert(formData);
					
					//发送异步
					$.ajax({
						type:"post",
						url:"{{U('Webset/add')}}",
						data:formData,
						dataType:'json',
						success:function(phpData){
							//var stt = "index.php?m=admin&c=webset&a=edit&id="+phpData.id;
							
							var str = '<tr class="msg-tr">'+
							'<td class="w230">'+phpData.navname+'</td>'+
							'<td>'+phpData.cate_id+'</td>'+
							'<td class="w200">'+phpData.navsort+'</td>'+
							'<td class="w200">'+
						//'<a href="'+stt+'" class="btn btn-primary btn-xs">编辑</a>&nbsp;&nbsp;'+
						'<a href="{{U('Webset/del')}}" class="btn btn-danger btn-xs">删除</a>'
							'</td>'+
							'</tr>';
							//选中最后一条，插入到后面
							$('.msg-tr:last').after(str);
							
						}
					});
					//阻止表单提交
					return false;
				})
			})
		</script>
		<style type="text/css">
			.w200{width:200px;}
			.w230{width: 230px;}
			.w100{width: 100px;}
		</style>
	</head>
	<body>
		<div class="alert alert-success">网站导航</div>
			<form action="" method="post" id="navform">
			<table class="table table-hover">
				<tr class="msg-tr">
					<th class="w230">导航名称</th>
					<th>分类ID</th>
					<th class="w200">导航排序</th>
					<th class="w200">操作</th>
				</tr>
				<tr class="msg-tr">
					<td class="w230"><input type="text" name="navname" id="" value="" class="form-control w200"/></td>
					<td>
						<select name="cate_id" id="cate_id" class="form-control w200">
							<option value="">-请选择-</option>
							{{foreach from="$gcateData" value="$v"}}
							<option value="{{$v['cate_id']}}">{{$v['_name']}}</option>
							{{endforeach}}
						</select>
					</td>
					<td class="w200">
						<input type="text" name="navsort" id="" value="" class="form-control  w100"/>
					</td>
					<td class="w200"></td>
				</tr>
			</table>

			<button class="btn btn-primary btn-block" type="submit"> 确定添加 </button>
			</form>
		

			<table class="table table-hover">
				<tr class="msg-tr">
					<th class="w230">导航名称</th>
					<th>分类ID</th>
					<th class="w200">导航排序</th>
					<th class="w200">操作</th>
				</tr>

				{{if value="is_array($data)"}}
				{{foreach from="$data" key="$k" value="$v"}}
				<tr class="msg-tr">
					<td class="w230">{{$v['navname']}}</td>
					<td>{{$v['cate_id']}}</td>
					<td class="w200">{{$v['navsort']}}</td>
					<td class="w200">
						<a href="{{U('Webset/edit',array('id'=>$k))}}" class="btn btn-primary btn-xs">编辑</a>&nbsp;&nbsp;
						<a href="{{U('Webset/del',array('id'=>$k))}}" class="btn btn-danger btn-xs">删除</a>
					</td>
				</tr>
				{{endif}}
				{{endforeach}}
			</table>
			

	</body>
</html>
